/**
 * Created by lw on 2015/11/10.
 */
$(function () {
    $("#xjyh_ht_id").combogrid({
        panelWidth: 640,
        delay: 500,
        mode: 'remote',
        idField: 'id',
        textField: 'htbm',
        fitColumns: true,
        pagination: true,//是否分页
        collapsible: false,//是否可折叠的
        fit: true,//自动大小
        pageSize: 10,//每页显示的记录条数，默认为10
        url: $.webPath() + '/htgl/cghtgl/bzjCghtList',
        columns: [
            [
                {field: 'id', hidden: true},
                {field: 'htbm', title: '合同号', width: 70},
                {field: 'hsze', title: '含税总额', width: 50},
                {field: 'hzf_jc', title: '供应商', width: 70},
                {field: 'sbgs_jc', title: '申报公司', width: 60},
                {field: 'qdrq', title: '签订日期', width: 30}
            ]
        ],
        loadFilter: function (data) {
            $.each(data.rows, function () {
                if (this.cglx) {
                    this.cglxz = this.cglx;
                    this.cglx = this.cglx == "bght" ? "保供合同" : this.cglx == "cgrk" ? "采购入库" : this.cglx == "zddh" ? "直达到货" : "统配合同";
                    this.zt = this.zt == 'yly' ? "已完结" : this.zt == 'yzz' ? "已终止" : this.zt == 'ytj' ? "已提交" : "已保存";
                }
            })
            return data;
        },
        onSelect: function () {
            var g = $('#xjyh_ht_id').combogrid('grid');	// 获取数据表格对象
            var r = g.datagrid('getSelected');	// 获取选择的行
            $.post($.webPath() + '/organ/gsjg/findXyKhByHtId_qclist', {htId: r.id}, function (data) {
                $("#xjyh_kh_id").val(data[0].qc);
            });
            $.post($.webPath() + '/zjgl/xjyh/findXsjeByHtid', {xjyhId: r.id}, function (data) {
                $("#xjyh_xsje").val(data[0].HSJ);
            });
        },
        onLoadSuccess: function () {
            if (xjyhOperType) {
                $('#xjyh_ht_id').combo('readonly');
            }
        }
    });
});
